public class ThreadDemo5 {
    public static void main(String[] args) throws InterruptedException {
        Object object = new Object();
        Thread a = new Thread(() -> {
            synchronized (object) {
                while (true) {
                    try {
                        System.out.print('a');
                        object.notify();
                        object.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        Thread b = new Thread(() -> {
            synchronized (object) {
                while (true) {
                    try {
                        System.out.print('b');
                        object.wait();
                        object.notify();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        Thread c = new Thread(() -> {
            synchronized (object) {
                while (true) {
                    try {
                        System.out.print('c');
                        object.wait();
                        object.notify();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        c.start();
        Thread.sleep(1000);
        b.start();
        Thread.sleep(1000);
        a.start();
        Thread.sleep(1000);

    }
}
